import FmGrid from './FmGrid.vue';

export const FM_GRID_OPTION = '__vue_fm_grid_option';

export const MAX_PAGE_SIZE = 200;

/**
 * 默认的props参数
 */
export const DEFAULT_PROPS = {
  page: 'page',
  size: 'size',
  rows: 'data.rows',
  total: 'data.total',
  paramsSerializer: undefined,
  pageSizes: [ 10, 20, 30],
  layout: 'total, sizes, prev, pager, next, jumper',
  style: 'border-top:none;float:right;padding-right:20px;'
};

/**
 * 
 * @param {} options options 配置
 * 例子 {
 *  axios: axios
 *  dataType: 'params',
 *  props: {
 *    page: 'page',
 *    size: 'pageNumber',
 *    data: 'data.result',
 *    total: 'data.dataNumber'
 *  }
 * }
 */
export default function install(Vue, options = {}) {
  if (options.axios) {
    Vue.prototype.$axios = options.axios;
    delete options.axios ;
  }
  if (!Vue.prototype.$axios) {
    throw new Error('请指定 axios!');
  }
  FmGrid[FM_GRID_OPTION] = options;
  Vue.component('fm-grid', FmGrid);

}